<?php echo $this->Html->script('cart'); ?>
<?php echo $this->Html->css('profile'); ?>
<?php echo $this->Html->css('category'); ?>
<?php echo $this->Html->css('deal'); ?>
<?php echo $this->Html->css('jquery.mCustomScrollbar'); ?>
<?php echo $this->Html->script('jquery.mCustomScrollbar'); ?>
<?php echo $this->Html->script('jquery.mousewheel.min'); ?>
<div id="catmain">
    <div class="span12">
        <?php if ($can_edit) { ?>
            <a href="<?=$this->webroot ?>users/edit_password" style="float:right" class="internal-home btn">Edit Password</a>
            <a href="<?=$this->webroot ?>users/profile" style="float:right" class="internal-home btn">Edit Profile</a>
            <a href="<?=$this->webroot ?>users/billing" style="float:right" class="internal-home btn">Edit Billing Info</a>
        <?php } ?>
        <?=$html->image($user_data['User']['avatar'], array('class' => 'profile-photo', 'id' => 'showAvatar')); ?>
        <div class="profile-top">
            <h1 class="profile-name"><?=$user_data['User']['name']?></h1>
            <span class="profile-tagline">
                <span><?=$user_data['User']['username'];?></span>
            </span>
        </div>

        <div class="profile-section">
            <div class="title" style="margin: 30px">SELLING ITEMS</div>
            <?php foreach($user_data['Deal'] as $deal) if ($deal['status'] == 0) { ?>
                <div class="drow profile-drow">
                    <div class="dleft profile-dleft">
                        <?= $html->image('posts/'.$deal['Product']['image'], array('class' => 'deal-picture profile-deal-picture')) ?>
                    </div>
                    <div class="dmid profile-dmid">
                        <a href="<?=$this->webroot?>products/view/<?=$deal['Product']['id']?>" class="dtitle"><?= $deal['Product']['name'] ?></a>
                        <p>Price: <?=$deal['price']?></p>
                    </div>
                    <div class="dright profile-dright">
                        <?php if (!$can_edit) { ?>
                            <?if (isset($deal['InCart']) && $deal['InCart']){?>
                                <div class="remove_from_cart btn" id="<?=$deal['id']?>_remove" style="width:100%">Remove from cart</div>
                                <div class="add_to_cart btn" id="<?=$deal['id']?>_add" style="display:none;width:100%">Add to cart</div>
                            <?}else{?>
                                <div class="add_to_cart btn" id="<?=$deal['id']?>_add" style="width:100%">Add to cart</div>
                                <div class="remove_from_cart btn" id="<?=$deal['id']?>_remove" style="display:none;width:100%">Remove from cart</div>
                            <?}?>
                        <?php } else { ?>
                            <a class="btn" style="text-decoration:none" href="<?=$this->webroot?>deals/view/<?=$deal['id']?>">View my deal</a>
                        <?php } ?>
                    </div>
                </div>
            <?php } ?>
            <?php if ($can_edit) { ?>
                <div class="title" style="clear:both;margin: 30px">MY ORDERS</div>
                <?php 
                $t = 0;
                foreach($orders as $order) { ?>
                    <div class="drow profile-drow" style="height:50px;width:51%">
                        <div class="dleft profile-dleft" style="width:15%;height:70%;padding-left:10%;padding-top:2.5%">
                            <?= ++$t ?>
                        </div>
                        <div class="dmid profile-dmid" style="width:45%;height:50%">
                            On <?=$order['Order']['created'] ?>
                        </div>
                        <div class="dright profile-dright" style="width:10%;height:50%">
                            <a href="<?=$this->webroot?>orders/view/<?=$order['Order']['id']?>" class="btn" style="margin-top:0px;margin-left:50%;color:black">
                                View
                            </a>
                        </div>
                    </div>
                <?php } ?>
            <?php } ?>
        </div>
    </div>
</div>
<script>
$(document).ready(function(){
    $('.scrollItem').mCustomScrollbar();
});
</script>
